package com.vikutorika.dao.imp;

import com.vikutorika.dao.SuspensionInfoDAO;
import com.vikutorika.dao.BasicDAO;
import com.vikutorika.entity.SuspensionInfo;
import com.vikutorika.entity.UserInfo;
import com.vikutorika.util.V_DBUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.Connection;
import java.util.List;

public class SuspensionInfoDAOImp extends BasicDAO<SuspensionInfo> implements SuspensionInfoDAO {
    @Override
    public List<SuspensionInfo> getAll() {
        return null;
    }

    @Override
    public int totalRow() {
        return 0;
    }

    @Override
    public SuspensionInfo getByUID(Integer uid) {
        Connection connection = null;
        try {
            connection = V_DBUtils.getConnection();
            String sql = "select * from suspension_info where uid = ?";
            QueryRunner runner = new QueryRunner();
            SuspensionInfo info = runner.query(connection, sql, new BeanHandler<>(SuspensionInfo.class), uid);
            return info;
        } catch (Exception e){
            throw new RuntimeException(e);
        } finally {
            V_DBUtils.close(null, null, connection);
        }
    }
}
